package com.minimalist.lindi.mapper;

import com.minimalist.common.entity.lindi.po.LindiPurchaseTownIndex;
import com.mybatisflex.core.BaseMapper;
import com.mybatisflex.core.query.QueryWrapper;

import java.util.List;

/**
 * 林地指标交易平台_镇街购买指标 映射层。
 *
 * @author 11987
 * @since 2025-07-01
 */
public interface LindiPurchaseTownIndexMapper extends BaseMapper<LindiPurchaseTownIndex>{

    /**
     * 根据购买指标记录ID查询镇街购买指标列表
     *
     * @param purchaseIndexRecordId 购买指标记录ID
     * @return 镇街购买指标列表
     */
    default List<LindiPurchaseTownIndex> selectByPurchaseIndexRecordId(Long purchaseIndexRecordId) {
        return selectListByQuery(QueryWrapper.create()
                .eq(LindiPurchaseTownIndex::getPurchaseIndexRecordId, purchaseIndexRecordId));
    }

    /**
     * 根据购买指标记录ID删除镇街购买指标
     *
     * @param purchaseIndexRecordId 购买指标记录ID
     * @return 删除的记录数
     */
    default int deleteByPurchaseIndexRecordId(Long purchaseIndexRecordId) {
        return deleteByQuery(QueryWrapper.create()
                .eq(LindiPurchaseTownIndex::getPurchaseIndexRecordId, purchaseIndexRecordId));
    }

}
